﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true"
    CodeBehind="JT_TitleManager.aspx.cs" Inherits="JTicket.UI.JT_TitleManager" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <!--分页Script-->
    <script type="text/jscript">
        var pages = 1;
        var page = 0;
        function pageselectCallback(page_id, jq) {
            var keyWord = $("#KeyWord").attr("value");
            window.location.href = "JT_TitleManager.aspx?KeyWord="
            + keyWord + "&page=" + page_id;
        }
        $(document).ready(function () {
            $("#pager").pagination(pages, {
                current_page: page,
                items_per_page: 1,
                first_text: "首页",
                prev_text: "上一页",
                next_text: "下一页",
                last_text: "尾页",
                ellipse_text: " ",
                callback: pageselectCallback
            });
            document.getElementById('txtBegin').value = new Date().format("yyyy-MM-dd HH:mm:ss");
            document.getElementById('txtEnd').value = new Date().format("yyyy-MM-dd HH:mm:ss");
            //剧院

            $.ajax({
                type: "get",
                url: "ThGetHandler.axd?Time=" + new Date(),
                success: function (msg) {
                    var arr = eval(msg.toString());
                    if (arr.length > 0) {
                        for (var i = 0; i < arr.length; i++) {
                            $("#seTheater").append("<option value=" +
                    arr[i].ThCode + ">" + arr[i].ThName + "</option>");
                        }
                    }
                },
                error: function () { isAlertError(); }
            });


            //类别
            $.ajax({
                type: "get",
                url: "TitleTypeHandler.axd?Time=" + new Date(),
                success: function (msg) {
                    var arr = eval(msg.toString());
                    if (arr.length > 0) {
                        for (var i = 0; i < arr.length; i++) {
                            $("#seSort").append("<option value=" +
                    arr[i].CodeVal + ">" + arr[i].CodeNote + "</option>");
                        }
                    }
                },
                error: function () { },
                async: false
            });



        });
        //添加
        function Add() {
            if ($('#txtTitle').val() == "") {
                alert("请输入剧目名称"); $("#txtTitle").focus(); return false;
            }
            if ($('#txtTeam').val() == "") {
                alert("请输入演出单位"); $("#txtTeam").focus(); return false;
            }
            if ($('#txtBegin').val() == "") {
                alert("请输入演出开始时间"); $("#txtBegin").focus(); return false;
            }
            if ($('#txtEnd').val() == "") {
                alert("请输入演出结束时间"); $("#txtEnd").focus(); return false;
            }
            if ($('#seTheater').val() == "-1") {
                alert("请选择剧院名称"); $("#seTheater").focus(); return false;
            }
            if ($('#seSort').val() == "-1") {
                alert("请选择演出类别"); $("#seSort").focus(); return false;
            }
            if ($('#SeStuts').val() == "-1") {
                alert("请选择剧目状态"); $("#SeStuts").focus(); return false;
            }
            var model = new JTicket.Model.D_TitleInfo();
            model.StitleCode = $('#txtBegin').val().
            replace(/\ /g, '').replace(/\:/g, '').
            replace(/\-/g, '') + $('#seTheater').val();
            model.Stitlename = $("#txtTitle").val();
            model.Steam = $("#txtTeam").val();
            model.Stheater = $("#seTheater").find("option:selected").text();
            model.Stitlesort = $("#seSort").find("option:selected").text();
            model.StitleInfo = $('#txtarea').val();
            model.Begindate = $('#txtBegin').val();
            model.EndDate = $('#txtEnd').val();
            model.TitleNum = $('#txtTilteNum').val();
            model.ThCode = $('#seTheater').val();
            model.Actor = $('#txtactor').val();
            model.note = $('#SeStuts').val();
            $("#BtnAdd").attr("disabled", "disabled");
            JTicket.UI.Service.JT_TitleSvc.Add(model,
            function Success(Result) {
                alert(Result);
                $("#BtnAdd").removeAttr("disabled");
                window.location.reload();
            }, isAlertError);
        }

        //查询
        function IsSelect() {
            window.location.href = "JT_TitleManager.aspx?KeyWord="
            + $("#KeyWord").attr("value") + "&page=0";
        }
        //删除
        function IsDels(Ids, Coms) {
            if (isdel()) {
                JTicket.UI.Service.JT_TitleSvc.Delete(Ids,
                function Succes() { window.location.reload(); },
                isAlertError);
            }
        }
        //批量删除
        function IsExc() {
            if (isdel()) {
                if (CheckValue() != "") {
                    JTicket.UI.Service.JT_TitleSvc.Deletes(CheckValue(),
                    function Succes() { window.location.reload(); },
                     isAlertError);
                }
            }
        }//设置状态
        function setStatu(a) { 
            $.ajax({
                type: "get",
                url: "TitleSetStatu.axd?TitleCode=" + a + "&Time=" + new Date(),
                success: function (msg) {
                     return msg;
                },
                 error: function () { } 
            }); 
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager ID="sm" runat="server">
        <Services>
            <asp:ServiceReference InlineScript="true" Path="~/Service/JT_TitleSvc.asmx" />
            <asp:ServiceReference InlineScript="true" Path="~/Service/JT_OperSvc.asmx" />
        </Services>
    </asp:ScriptManager>
    <input type="hidden" id="titlecode" value="" />
    <table align="center" border="0" cellpadding="4" cellspacing="1" class="toptable grid"
        width="100%">
        <tr>
            <td class="category t2" height="25" width="100px">
                剧目管理
            </td>
            <td class="category" height="25">
                <input id="KeyWord" class="input" type="text" /><input type="button" id="BtnSelete"
                    value="查  询" onclick="IsSelect();" onmousemove="showBtnOver(this)" onmouseout="showBtnOut(this)"
                    class="submitMiniGreen" /><input type="button" id="BtnAdd" value="添  加" onclick="Add();"
                        onmousemove="showBtnOver(this)" onmouseout="showBtnOut(this)" class="submitMiniGreen" />
            </td>
        </tr>
    </table>
    <table width="100%" border="0" bordercolordark="#3890B5" bordercolorlight="#6591BE"
        align="center" cellpadding="1" cellspacing="1">
        <tr>
            <td bgcolor="#f6f6f6" align="right" style="width: 100px">
                剧目名称：
            </td>
            <td align="left" bgcolor="#f6f6f6" style="width: 240px">
                <input id="txtTitle" class="input" type="text" />
            </td>
            <td align="right" bgcolor="#f6f6f6" height="25" style="width: 100px">
                演出单位：
            </td>
            <td align="left" bgcolor="#f6f6f6">
                <input id="txtTeam" class="input" type="text" />
            </td>
        </tr>
        <tr>
            <td align="right" bgcolor="#f6f6f6" style="width: 100px">
                上演时间起：
            </td>
            <td align="left" bgcolor="#f6f6f6">
                <input id="txtBegin" class="input" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
            </td>
            <td align="right" bgcolor="#f6f6f6" height="25" style="width: 100px">
                上演时间止：
            </td>
            <td align="left" bgcolor="#f6f6f6">
                <input id="txtEnd" class="input" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
            </td>
        </tr>
        <tr>
            <td align="right" bgcolor="#f6f6f6" style="width: 100px; height: 30px;">
                场次：
            </td>
            <td align="left" bgcolor="#f6f6f6" style="height: 30px">
                <input id="txtTilteNum" class="input" type="text" value="场次1" />
            </td>
            <td align="right" bgcolor="#f6f6f6" style="width: 100px; height: 30px;">
                演出类别：
            </td>
            <td align="left" bgcolor="#f6f6f6" style="height: 30px">
                <select id="seSort" name="D1">
                    <option value="-1">--选择演出类别--</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="right" bgcolor="#f6f6f6" style="width: 100px">
                场馆：
            </td>
            <td align="left" bgcolor="#f6f6f6">
                <select id="seTheater" name="D1">
                    <option value="-1">--请选择场馆名称--</option>
                </select>
            </td>
            <td align="right" bgcolor="#f6f6f6" height="25" style="width: 100px">
                剧目状态：
            </td>
            <td align="left" bgcolor="#f6f6f6">
                <select id="SeStuts" name="D2">
                    <option value="-1">--选择剧目状态--</option>
                    <option value="1">正常</option>
                    <option value="0">锁定</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="right" bgcolor="#f6f6f6" style="width: 100px">
                主要演员：
            </td>
            <td align="left" bgcolor="#f6f6f6">
                <textarea id="txtactor" class="textarea" cols="20" name="S2" style="height: 50px;
                    width: 300px;" rows="1"></textarea>
            </td>
            <td align="right" bgcolor="#f6f6f6" height="25" style="width: 100px">
                简介：
            </td>
            <td align="left" bgcolor="#f6f6f6">
                <textarea id="txtarea" class="textarea" cols="20" name="S1" style="height: 50px;
                    width: 300px;" rows="1"></textarea>
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#f6f6f6" style="width: 100px">
            </td>
            <td align="left" bgcolor="#f6f6f6">
            </td>
            <td align="center" bgcolor="#f6f6f6" height="25" style="width: 100px">
            </td>
            <td align="left" bgcolor="#f6f6f6">
            </td>
        </tr>
    </table>
    <br />
    <table cellpadding="1" cellspacing="1" id="TbInfo" class="TbInfo">
        <tr>
            <td class="B" style="width: 5%">
                选择
            </td>
            <td class="B" style="width: 15%">
                剧目编号
            </td>
            <td class="B">
                剧目名称
            </td>
            <td class="B" style="width: 6%">
                场次号
            </td>
            <td class="B" style="width: 10%">
                演出日期
            </td>
            <td class="B" style="width: 10%">
                演出时间
            </td>
            <td class="B" style="width: 7%">
                演出类别
            </td>
            <td class="B" style="width: 10%">
                剧院编号
            </td> 
            <td class="B" style="width: 7%">
                销售政策
            </td>
            <td class="B" style="width: 4%">
                状态
            </td>
            <td class="B" style="width: 5%">
                修改
            </td>
            <td class="B" style="width: 5%">
                删除
            </td>
        </tr>
        <%foreach (var Title in _TitleInfo)
          { %>
        <tr>
            <td class="td1">
                <input name="cb" type="checkbox" value="<%=Title.StitleCode%>" style="border: 0;
                    width: 20px" />
            </td>
            <td class="td1">
                <%=Title.StitleCode%>
            </td>
            <td class="td1">
                <%=Title.Stitlename%>
            </td>
            <td class="td1">
                <%=Title.TitleNum%>
            </td>
            <td class="td1">
                <%=Title.Begindate.Value.ToString("yyyy年MM月dd日")%>
            </td>
            <td class="td1">
                <%=Title.Begindate.Value.ToString("HH时mm分ss秒")%>
            </td>
            <td class="td1">
                <%=Title.Stitlesort%>
            </td>
            <td class="td1">
                <%=Title.ThCode%>
            </td>
            <td class="td1">
               <a href="JT_SaleZC.aspx?TitleCode=<%=Title.StitleCode%>&ThCode=<%=Title.ThCode%>&Title=<%=Title.Stitlename%>">设置</a>
            </td> 
            <td class="td1">
               <a href="#" onclick="setStatu('<%=Title.StitleCode%>');$(this).html($(this).html()=='锁定'?'正常':'锁定');"><%=(Title.note=="1")?"正常":"锁定"%></a>
            </td>
            <td class="td2">
                <img src="Images/icon_edit.gif" alt="编辑" style="cursor: hand" onclick="javascript:window.location.href ='JT_TitleAdd.aspx?TitleCode=<%=Title.StitleCode

%>';" />
            </td>
            <td class="td2">
                <img src="Images/no.gif" alt="删除" style="cursor: hand" onclick="javascript:IsDels('<%=Title.StitleCode

%>');" />
            </td>
        </tr>
        <%}%>
    </table>
    <div id="pager" class="pagination" style="background: #FFFFFF">
    </div>
    <table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
        <tr bgcolor="#E7E7E7">
            <td align="center" bgcolor="#E7E7E7" style="color: #000000" colspan="4">
                <input id="chkall" type="checkbox" class="checkbox" onclick="CheckAll(this.form)"
                    style="border: 0" />全选<asp:DropDownList ID="DropDownList1" runat="server">
                        <asp:ListItem Value="1">---删除所选---</asp:ListItem>
                    </asp:DropDownList>
                <input type="button" id="Button1" value="执行操作" onclick="return IsExc()" onmousemove="showBtnOver(this)"
                    onmouseout="showBtnOut(this)" class="submitMiniGreen" />
            </td>
        </tr>
    </table>
</asp:Content>
